package com.cn.delan.web.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.cn.delan.core.util.ValidCodeUtil;
import com.cn.delan.web.mvc.core.CoreConst;

public class ValidCodeServlet extends HttpServlet {
	private static final long serialVersionUID = 7280577575868908935L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse res)
			throws ServletException, IOException {
		ServletOutputStream out = res.getOutputStream();
		HttpSession session = req.getSession();
		String valid = ValidCodeUtil.createValidCodeImage(60, 4, out);
		session.setAttribute(CoreConst.SESSION_ATTR_VALIDCODE, valid);
	}
}
